package com.hengfoxwolf.bannerdemo
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.view.LayoutInflater
import androidx.viewbinding.ViewBinding
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.MainScope

abstract class BaseActivity<VB : ViewBinding>(open val block: (LayoutInflater) -> VB) : AppCompatActivity(),CoroutineScope by MainScope() {

    private lateinit var _binding: VB
    protected val mBinding get() = _binding

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        _binding = block(layoutInflater)
        setContentView(_binding.root)
        init(savedInstanceState)
    }

    protected abstract fun init(savedInstanceState: Bundle?)
}